int gcd(int a, int b)
{
    while (b)
    {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int findGCD(int *nums, int numsSize)
{
    int min = 1001, max = 0;
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] > max)
        {
            max = nums[i];
        }
        if (nums[i] < min)
        {
            min = nums[i];
        }
    }
    int ans = gcd(max, min);
    return ans;
}